package com.sixth.service.impl;

import com.github.pagehelper.util.StringUtil;
import com.sixth.annotation.PageInfoAdvice;
import com.sixth.bean.MarketLogExample;
import com.sixth.bean.common.BasePageInfo;
import com.sixth.mapper.MarketLogMapper;
import com.sixth.service.AdminLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName AdminLogServiceImpl
 * @Description TODO
 * @Author XiaoWJ
 * @Date 2022/9/8 16:47
 **/
@Transactional
@Service
public class AdminLogServiceImpl implements AdminLogService {

    @Autowired
    MarketLogMapper marketLogMapper;


    @PageInfoAdvice
    @Override
    public Object list(BasePageInfo basePageInfo, String name) {
        MarketLogExample example = new MarketLogExample();

        example.setOrderByClause(basePageInfo.getSort() + " " + basePageInfo.getOrder()  );

        MarketLogExample.Criteria criteria = example.createCriteria();

        if (!StringUtil.isEmpty(name)){
            criteria.andAdminLike("%" + name.toUpperCase().trim() + "%");

        }

        return marketLogMapper.selectByExample(example);

    }
}
